import { useIntersectionObserver } from '@vueuse/core';
import { onMounted, ref } from 'vue';

export function useLazyData(fn:()=>void){
  const target = ref(null)

onMounted(()=>{
  const { stop } = useIntersectionObserver(target.value,([{ isIntersecting }]) =>{
    if(isIntersecting){
      
      fn()

      stop()
    }
  } )
})
return target
}
